package com.ruoyi.web.controller.fruiteasepay;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fep.domain.Installments;
import com.ruoyi.fep.service.IInstallmentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 付款详情Controller
 * 
 * @author zj
 * @date 2023-04-12
 */
@RestController
@RequestMapping("/fep/installments")
public class InstallmentsController extends BaseController
{
    @Autowired
    private IInstallmentsService installmentsService;

    /**
     * 查询付款详情列表
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:list')")
    @GetMapping("/list")
    public TableDataInfo list(Installments installments)
    {
        startPage();
        List<Installments> list = installmentsService.selectInstallmentsList(installments);
        return getDataTable(list);
    }

    /**
     * 导出付款详情列表
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:export')")
    @Log(title = "付款详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Installments installments)
    {
        List<Installments> list = installmentsService.selectInstallmentsList(installments);
        ExcelUtil<Installments> util = new ExcelUtil<Installments>(Installments.class);
        util.exportExcel(response, list, "付款详情数据");
    }

    /**
     * 获取付款详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:query')")
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return success(installmentsService.selectInstallmentsByPayId(payId));
    }

    /**
     * 新增付款详情
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:add')")
    @Log(title = "付款详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Installments installments)
    {
        return toAjax(installmentsService.insertInstallments(installments));
    }

    /**
     * 修改付款详情
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:edit')")
    @Log(title = "付款详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Installments installments)
    {
        return toAjax(installmentsService.updateInstallments(installments));
    }

    /**
     * 删除付款详情
     */
    @PreAuthorize("@ss.hasPermi('fep:installments:remove')")
    @Log(title = "付款详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payIds}")
    public AjaxResult remove(@PathVariable Long[] payIds)
    {
        return toAjax(installmentsService.deleteInstallmentsByPayIds(payIds));
    }
}
